class Favorite {
  int? id;
  int userId;
  int contentId;
  DateTime? createdAt;

  Favorite({
    this.id,
    required this.userId,
    required this.contentId,
    this.createdAt,
  });

  Map<String, dynamic> toMap() {
    return {
      'id': id,
      'userId': userId,
      'contentId': contentId,
      'createdAt': createdAt?.millisecondsSinceEpoch,
    };
  }

  factory Favorite.fromMap(Map<String, dynamic> map) {
    return Favorite(
      id: map['id'],
      userId: map['userId'],
      contentId: map['contentId'],
      createdAt: map['createdAt'] != null
          ? DateTime.fromMillisecondsSinceEpoch(map['createdAt'])
          : null,
    );
  }

  Favorite copyWith({
    int? id,
    int? userId,
    int? contentId,
    DateTime? createdAt,
  }) {
    return Favorite(
      id: id ?? this.id,
      userId: userId ?? this.userId,
      contentId: contentId ?? this.contentId,
      createdAt: createdAt ?? this.createdAt,
    );
  }
}
